package game.particle;

import engine.j2d.Color;
import engine.math.Vector2f;

public class Fire extends ParticleSystem
{
	public Fire(String pathTex, int num, float life,Vector2f pos,
			Vector2f partSize,Color color)
	{
		super(pathTex, 0, 0, null, null, null, null);
		particles = new Particle[num];
		for (int i = 0; i < particles.length; i++) {
			fire();
			particles[i] = new Particle(new Vector2f(pos.x, pos.y), partSize,
					new Vector2f(xs, ys), color, life);
			fade = (float) (Math.random() % 100) / 100.0f + 0.5f;
			particles[i].setDLife(fade);
		}
	}
	private void fire()
	{
		float xp = (float) (Math.random() * 2) - 1;
		float yp = (float) (Math.random() * 2) + 1;
		if (xp == 0) {
			xp = 1.2f;
		}
		if (yp == 0) {
			yp = 1.2f;
		}
		ang = (float) (Math.random() * 40) + 70;
		xs = (float) Math.cos((2 * pi * ang) / 360.0) / (xp + 2);
		ys = -(float) Math.sin((2 * pi * ang) / 360.0) * (yp);
	}
}
